package part1;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Java5Ex3 Example of covariant returns
 * 
 * @author tony
 * 
 */

class A {
	private int data = 4;
	public A make() {
		return new A();
	}
}

class B extends A {
	// Before Java 5, overriding the make method meant we were limited to
	//  having make return only A objects:
	// public A make(){ return new A(); }
	
	// With Java 5, the make method can return any subclass of A
	public B make() {
		return new B();
	}
}

public class Java5Ex3 {
	public static void main(String[] args) {
		A a = new A();
		System.out.println(" a.make returned " + a.make());
		A b = new B();
		System.out.println(" b.make returned " + b.make());

	}
}